// 插件
import "../plugins/rem";
import store from "../store";
import router from "../router";
import vanUIComponent from "@/plugins/vantUI";
import _ from "lodash";
import api, { IApi } from "@/plugins/request";
import { utils, IUtils } from "../utils/common";
// 属性
import "../styles/index.scss";
import { showToast } from "vant";
// 定义全局插件
export const initPlugins: any = {
  router,
  store,
  ...vanUIComponent,
};
// 定义全局属性
export const initAttribute: any = {
  _,
  $: (window as any).$,
  api,
  showToast,
  utils,
};

export const miscVueInitPlugin = (app: any) => {
  // 注册全局插件
  Object.keys(initPlugins).forEach((x) => {
    app.use(initPlugins[x]);
  });
  // 注册全局属性
  Object.keys(initAttribute).forEach((x) => {
    app.config.globalProperties[`$` + x] = initAttribute[x];
  });
};
declare module "@vue/runtime-core" {
  interface ComponentCustomProperties {
    $_: any;
    $api: IApi;
    $showToast: any;
    $utils: IUtils;
  }
}
